$OpenBSD: patch-window-copy_c,v 1.1.1.1 2017/02/16 20:06:03 jasper Exp $

From b27f3bacc0308a86a5f3e3494bd0383cd7583971 Mon Sep 17 00:00:00 2001
From: Nicolas Viennot <nicolas@viennot.biz>
Date: Fri, 10 Jun 2016 18:00:50 -0400
Subject: [PATCH] Crash fix in search prev/next match

--- window-copy.c.orig	Tue Mar 29 05:30:07 2016
+++ window-copy.c	Wed Feb  8 19:49:29 2017
@@ -1054,6 +1054,11 @@ window_copy_search_up(struct window_pane *wp, const ch
 	int				 n, wrapped, wrapflag, cis;
 	const char			*ptr;
 
+#ifdef TMATE
+	if (!searchstr)
+		return;
+#endif
+
 	if (*searchstr == '\0')
 		return;
 	wrapflag = options_get_number(wp->window->options, "wrap-search");
@@ -1119,6 +1124,11 @@ window_copy_search_down(struct window_pane *wp, const 
 	u_int				 i, first, fx, fy, px;
 	int				 n, wrapped, wrapflag, cis;
 	const char			*ptr;
+
+#ifdef TMATE
+	if (!searchstr)
+		return;
+#endif
 
 	if (*searchstr == '\0')
 		return;
